package com.woniuxy.micromallserver.ordermag.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.common.bean.PageDto;
import com.woniuxy.micromallserver.bean.AfterSaleServiceBean;
import com.woniuxy.micromallserver.ordermag.mapper.AfterSaleServiceMapper;
import com.woniuxy.micromallserver.ordermag.service.IAfterSaleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author unreleased
 * @date 2021/2/1 11:24
 */
@Service
public class AfterSaleServiceImpl implements IAfterSaleService {
    @Resource
    private AfterSaleServiceMapper afterSaleServiceMapper;

    /**
     * 按条件查询售后服务工单
     *
     * @param afterSaleServiceBean 携带查询参数的Bean
     * @param pageNum 页码数
     * @param pageSize 页面条数
     * @return 分页对象
     */
    @Override
    public PageDto findAfterSaleServiceListByParams(AfterSaleServiceBean afterSaleServiceBean, Integer pageNum, Integer pageSize) {
        if(pageNum<=0){
            return null;
        }
        PageHelper.startPage(pageNum, pageSize);
        List<AfterSaleServiceBean> data = afterSaleServiceMapper.findAfterSaleServiceListByParams(afterSaleServiceBean);
        PageInfo<AfterSaleServiceBean> pageInfo = new PageInfo<>(data);

        PageDto pageDto = new PageDto();
        pageDto.setTotal(pageInfo.getTotal());
        pageDto.setData(data);
        return pageDto;
    }

    @Override
    public boolean updateStatus(Long id, String handleStatus) {
        return afterSaleServiceMapper.updateStatus(id,handleStatus);
    }
}
